.class public Lcom/philzhu/www/framework/impl/SingleTouchHandler;
.super Ljava/lang/Object;
.source "SingleTouchHandler.java"

# interfaces
.implements Lcom/philzhu/www/framework/impl/TouchHandler;


# instance fields
.field isTouched:Z

.field scaleX:F

.field scaleY:F

.field touchEventPool:Lcom/philzhu/www/framework/Pool;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Lcom/philzhu/www/framework/Pool",
            "<",
            "Lcom/philzhu/www/framework/Input$TouchEvent;",
            ">;"
        }
    .end annotation
.end field

.field touchEvents:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List",
            "<",
            "Lcom/philzhu/www/framework/Input$TouchEvent;",
            ">;"
        }
    .end annotation
.end field

.field touchEventsBuffer:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List",
            "<",
            "Lcom/philzhu/www/framework/Input$TouchEvent;",
            ">;"
        }
    .end annotation
.end field

.field touchX:I

.field touchY:I


# direct methods
.method public constructor <init>(Landroid/view/View;FF)V
    .locals 3
    .parameter "view"
    .parameter "scaleX"
    .parameter "scaleY"

    .prologue
    .line 23
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 18
    new-instance v1, Ljava/util/ArrayList;

    invoke-direct {v1}, Ljava/util/ArrayList;-><init>()V

    iput-object v1, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->touchEvents:Ljava/util/List;

    .line 19
    new-instance v1, Ljava/util/ArrayList;

    invoke-direct {v1}, Ljava/util/ArrayList;-><init>()V

    iput-object v1, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->touchEventsBuffer:Ljava/util/List;

    .line 24
    new-instance v0, Lcom/philzhu/www/framework/impl/SingleTouchHandler$1;

    invoke-direct {v0, p0}, Lcom/philzhu/www/framework/impl/SingleTouchHandler$1;-><init>(Lcom/philzhu/www/framework/impl/SingleTouchHandler;)V

    .line 30
    .local v0, factory:Lcom/philzhu/www/framework/Pool$PoolObjectFactory;,"Lcom/philzhu/www/framework/Pool$PoolObjectFactory<Lcom/philzhu/www/framework/Input$TouchEvent;>;"
    new-instance v1, Lcom/philzhu/www/framework/Pool;

    const/16 v2, 0x64

    invoke-direct {v1, v0, v2}, Lcom/philzhu/www/framework/Pool;-><init>(Lcom/philzhu/www/framework/Pool$PoolObjectFactory;I)V

    iput-object v1, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->touchEventPool:Lcom/philzhu/www/framework/Pool;

    .line 31
    invoke-virtual {p1, p0}, Landroid/view/View;->setOnTouchListener(Landroid/view/View$OnTouchListener;)V

    .line 33
    iput p2, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->scaleX:F

    .line 34
    iput p3, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->scaleY:F

    .line 35
    return-void
.end method


# virtual methods
.method public getTouchEvents()Ljava/util/List;
    .locals 4
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/List",
            "<",
            "Lcom/philzhu/www/framework/Input$TouchEvent;",
            ">;"
        }
    .end annotation

    .prologue
    .line 91
    monitor-enter p0

    .line 92
    :try_start_0
    iget-object v2, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->touchEvents:Ljava/util/List;

    invoke-interface {v2}, Ljava/util/List;->size()I

    move-result v1

    .line 93
    .local v1, len:I
    const/4 v0, 0x0

    .local v0, i:I
    :goto_0
    if-lt v0, v1, :cond_0

    .line 95
    iget-object v2, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->touchEvents:Ljava/util/List;

    invoke-interface {v2}, Ljava/util/List;->clear()V

    .line 96
    iget-object v2, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->touchEvents:Ljava/util/List;

    iget-object v3, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->touchEventsBuffer:Ljava/util/List;

    invoke-interface {v2, v3}, Ljava/util/List;->addAll(Ljava/util/Collection;)Z

    .line 97
    iget-object v2, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->touchEventsBuffer:Ljava/util/List;

    invoke-interface {v2}, Ljava/util/List;->clear()V

    .line 98
    iget-object v2, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->touchEvents:Ljava/util/List;

    monitor-exit p0

    return-object v2

    .line 94
    :cond_0
    iget-object v3, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->touchEventPool:Lcom/philzhu/www/framework/Pool;

    iget-object v2, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->touchEvents:Ljava/util/List;

    invoke-interface {v2, v0}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Lcom/philzhu/www/framework/Input$TouchEvent;

    invoke-virtual {v3, v2}, Lcom/philzhu/www/framework/Pool;->free(Ljava/lang/Object;)V

    .line 93
    add-int/lit8 v0, v0, 0x1

    goto :goto_0

    .line 91
    .end local v0           #i:I
    .end local v1           #len:I
    :catchall_0
    move-exception v2

    monitor-exit p0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v2
.end method

.method public getTouchX(I)I
    .locals 1
    .parameter "pointer"

    .prologue
    .line 77
    monitor-enter p0

    .line 78
    :try_start_0
    iget v0, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->touchX:I

    monitor-exit p0

    return v0

    .line 77
    :catchall_0
    move-exception v0

    monitor-exit p0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v0
.end method

.method public getTouchY(I)I
    .locals 1
    .parameter "pointer"

    .prologue
    .line 84
    monitor-enter p0

    .line 85
    :try_start_0
    iget v0, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->touchY:I

    monitor-exit p0

    return v0

    .line 84
    :catchall_0
    move-exception v0

    monitor-exit p0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v0
.end method

.method public isTouchDown(I)Z
    .locals 1
    .parameter "pointer"

    .prologue
    .line 67
    monitor-enter p0

    .line 68
    if-nez p1, :cond_0

    .line 69
    :try_start_0
    iget-boolean v0, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->isTouched:Z

    monitor-exit p0

    .line 71
    :goto_0
    return v0

    :cond_0
    monitor-exit p0

    const/4 v0, 0x0

    goto :goto_0

    .line 67
    :catchall_0
    move-exception v0

    monitor-exit p0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v0
.end method

.method public onTouch(Landroid/view/View;Landroid/view/MotionEvent;)Z
    .locals 4
    .parameter "v"
    .parameter "event"

    .prologue
    const/4 v3, 0x1

    .line 39
    monitor-enter p0

    .line 40
    :try_start_0
    iget-object v1, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->touchEventPool:Lcom/philzhu/www/framework/Pool;

    invoke-virtual {v1}, Lcom/philzhu/www/framework/Pool;->newObject()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/philzhu/www/framework/Input$TouchEvent;

    .line 41
    .local v0, touchEvent:Lcom/philzhu/www/framework/Input$TouchEvent;
    invoke-virtual {p2}, Landroid/view/MotionEvent;->getAction()I

    move-result v1

    packed-switch v1, :pswitch_data_0

    .line 57
    :goto_0
    invoke-virtual {p2}, Landroid/view/MotionEvent;->getX()F

    move-result v1

    iget v2, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->scaleX:F

    mul-float/2addr v1, v2

    float-to-int v1, v1

    iput v1, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->touchX:I

    iput v1, v0, Lcom/philzhu/www/framework/Input$TouchEvent;->x:I

    .line 58
    invoke-virtual {p2}, Landroid/view/MotionEvent;->getY()F

    move-result v1

    iget v2, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->scaleY:F

    mul-float/2addr v1, v2

    float-to-int v1, v1

    iput v1, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->touchY:I

    iput v1, v0, Lcom/philzhu/www/framework/Input$TouchEvent;->y:I

    .line 59
    iget-object v1, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->touchEventsBuffer:Ljava/util/List;

    invoke-interface {v1, v0}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 61
    monitor-exit p0

    return v3

    .line 43
    :pswitch_0
    const/4 v1, 0x0

    iput v1, v0, Lcom/philzhu/www/framework/Input$TouchEvent;->type:I

    .line 44
    const/4 v1, 0x1

    iput-boolean v1, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->isTouched:Z

    goto :goto_0

    .line 39
    .end local v0           #touchEvent:Lcom/philzhu/www/framework/Input$TouchEvent;
    :catchall_0
    move-exception v1

    monitor-exit p0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v1

    .line 47
    .restart local v0       #touchEvent:Lcom/philzhu/www/framework/Input$TouchEvent;
    :pswitch_1
    const/4 v1, 0x2

    :try_start_1
    iput v1, v0, Lcom/philzhu/www/framework/Input$TouchEvent;->type:I

    .line 48
    const/4 v1, 0x1

    iput-boolean v1, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->isTouched:Z

    goto :goto_0

    .line 52
    :pswitch_2
    const/4 v1, 0x1

    iput v1, v0, Lcom/philzhu/www/framework/Input$TouchEvent;->type:I

    .line 53
    const/4 v1, 0x0

    iput-boolean v1, p0, Lcom/philzhu/www/framework/impl/SingleTouchHandler;->isTouched:Z
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_0

    .line 41
    :pswitch_data_0
    .packed-switch 0x0
        :pswitch_0
        :pswitch_2
        :pswitch_1
        :pswitch_2
    .end packed-switch
.end method
